/*
 * BaseLayout.fx
 *
 * Created on 2009-08-31, 14:11:51
 */

package shmallarchitect.gui;

import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;

import javafx.scene.Group;
import javafx.scene.CustomNode;
import javafx.scene.Node;

import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;

import javafx.scene.text.Font;
import javafx.scene.text.Text;

import javafx.scene.transform.Translate;
import shmallarchitect.java.Owner;
import shmallarchitect.java.Locuma;
import shmallarchitect.java.Resource;
public var sequence: Integer[]; // wybrane pola

/* baselocum
*   To domyslny lokal dla wszystkich squareow na poczatku.
*   Zawsze pierwszy na liscie.
*
*   baseowner
*   Jak baselocum tylko ze ownerow
*/

var lala = [0,0,0];

public var baseowner = new Owner("Gallery","This is owned by the Gallery", "None", "", "");
public var baselocum = new Locuma(0, Color.web("#6b6b6b"), "Not Assigned", 0, lala);
public var baseresource = new Resource(0, "{__DIR__}noimg.jpg");


/* local_list
*   To jest lista lokali na danym poziomie. Dwie wazne rzeczy:
*   1. Tu beda wpisane wszystkie lokale ktore potem trzeba przeklepac do bazy
*   2. Do tego trzeba wpisac wszystkie lokale wyjete z bazy przy wczytywaniu galerii
*/
public var local_list : Locuma[]; // lokale
public var owner_list: Owner[]; // Ownerzy
public var resource_list: Resource[];

public var hoverid: Integer;

/* debug
*   tu mozna wypisac cos :P
*/
var test = bind getLocuma();
public var debug = bind EditDetails.resourcelist;

public var editmode: Boolean = false;


public var mode: Boolean = true;

// Funkcja zwraca Locuma o id:
// W EditMode: pierwszy wybrany w sequence
// W ViewMode: hover


public function getLocuma():Locuma {

        var locid:Integer; //id: w EditM id wybranego, w ViewMode id hovered

        if(editmode == false) { locid = hoverid; }
        else {locid = board.squares[sequence[0]].localid; }

        return local_list[locid];
        }

public var board = Board
{
    horizontalSpaces: 50
    verticalSpaces: 30
    gridHeight: 600;
    gridWidth: 1000;

    transforms: [
        Translate { x: 40; y: 60; }
    ]

    visible: bind mode;

};

/**
 * @author Administrator
 */

 public class BaseLayout extends CustomNode {

         public override function create(): Node {
                 return Group {
                         content: [

                         Rectangle { // tlo calosci
                                  x: 0, y: 0
                                  width: 1100, height: 800
                                  fill: Color.web ("#626262");
                                  },

                          Rectangle { // gorny pasek
                                  x: 0, y: 0
                                  width: 1100, height: 20

                     fill: LinearGradient {
                     startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                     proportional: true
                     stops: [ Stop { offset: 0.0 color: Color.web ("#4a4a4a") },
                     Stop { offset: 1.0 color: Color.web ("#404040")} ] }
                                    },

                     Rectangle  // dolny pasek
                               {
                                  x: 0, y: 700
                                  width: 1100, height: 100

                     fill: LinearGradient {
                     startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                     proportional: true
                     stops: [ Stop { offset: 0.0 color: Color.web ("#4a4a4a") },
                     Stop { offset: 1.0 color: Color.web ("#404040")} ] }
                                    },

                      Text { x: 20 y: 15 //wersja
                                    font: Font.font("Verdana", 12);
                                    fill: Color.WHITE
                                    content: "ShMall Gallery v0.3"
                                    },

                      Text { x: 60 y: 40 // ID po hoverze
                                    font: Font.font("Verdana", 12);
                                    fill: Color.web("#b4b8a2")
                                    content: bind "ID: {hoverid}";

                                    visible: bind mode;
                                    },

                      Text { x: 130 y: 40 // wybrane id
                                    font: Font.font("Verdana", 10);
                                    fill: Color.web("#b4b8a2")
                                    content: bind "Clicked ID: {sequence} ";

                                    visible: bind mode;
                                    },

                       Text { x: 200 y: 680 // DEBUG
                                    font: Font.font("Verdana", 10);
                                    fill: Color.web("#b4b8a2")
                                    content: bind "DEBUG: {debug} ";
                                    },

                       Text { x: 60 y: 680 // Localname
                                    font: Font.font("Verdana", 10);
                                    fill: Color.web("#b4b8a2")
                         content: bind "Local: {local_list[board.get_localid(hoverid)].name} ";
                                    },

                                    EditControls{},

                                 ]
                 };
         }
 }
